local frame = CreateFrame("Frame", "QCFrame", UIParent)
local editbox = CreateFrame("EditBox", nil, frame)

frame:Hide()
frame:SetBackdrop({
		bgFile = "Interface\\ChatFrame\\ChatFrameBackground", tile = true, tileSize = 16,
		edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", edgeSize = 16,
		insets = {left = 4, right = 4, top = 4, bottom = 4},
})
frame:SetWidth(175)
frame:SetHeight(40)

frame:EnableMouse(true)
frame:SetMovable(true)
frame:RegisterForDrag"LeftButton"

frame:SetUserPlaced(true)
frame:SetScript("OnDragStart", function(self) self:StartMoving() end)
frame:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
frame:SetBackdropColor(0, 0, 0)
frame:SetBackdropBorderColor(0, 0, 0)
frame:SetPoint("CENTER", UIParent)

editbox:SetFont(STANDARD_TEXT_FONT, 12)
editbox:SetAutoFocus(true)

local onKeyPressed = function(self)
	if(editbox:GetText() == "") then
		frame:Hide()
		editbox:ClearFocus()
	end
end

editbox:SetScript("OnEscapePressed", onKeyPressed)
editbox:SetScript("OnTextChanged", onKeyPressed)
editbox:SetJustifyH("CENTER")
editbox:SetWidth(150)
editbox:SetHeight(15)
editbox:SetPoint("CENTER", frame, "CENTER", 0, 0)
frame.editbox = editbox

local onClick = function(self)
	if(IsAltKeyDown()) then
		local num = GetQuestLogSelection()
		local name = GetQuestLogTitle(num)

		frame:Show()
		editbox:SetText(name)
		editbox:HighlightText()
	end
end

for i=1,6 do
	hooksecurefunc("QuestLogTitleButton_OnClick", onClick)
end
